// const isType = type => target => `[object ${type}]` === Object.prototype.toString.call(target)
// const isArray = isType('Array')
// const isNull = isType('Null')

const selfMap = function (fn, context) {
  console.log(fn, context)
  let arr = Array.prototype.slice.call(this)
  let mappedArr = Array()
  for (let i = 0; i < arr.length; i++) {
    if (!arr.hasOwnProperty(i)) continue;
    mappedArr[i] = fn.call(context, arr[i], i, this)
  }
  return mappedArr
}

Array.prototype.selfMap = selfMap
const a = new Array(1,2,3)

console.log(a.selfMap((number, index, context) => {
  return number * 2
}, { a: 10 }))